package io.github.lee.repository.jel.domain

import android.content.Context
import android.os.Parcelable
import androidx.annotation.Keep
import androidx.core.net.toUri
import com.google.gson.annotations.SerializedName
import io.github.lee.repository.jel.data.session
import kotlinx.parcelize.Parcelize


@Keep
@Parcelize
data class People(
    @SerializedName("Id")
    val id: String? = "",
    @SerializedName("Name")
    val name: String? = "",
    @SerializedName("PrimaryImageTag")
    val primaryImageTag: String? = "",
    @SerializedName("Role")
    val role: String? = "",
    @SerializedName("Type")
    val type: String? = ""
) : Parcelable {
    fun fullAvatar(context: Context): String {
        val builder = context.session?.host?.toUri()?.buildUpon()
            ?.appendEncodedPath("Items/$id/Images/Primary")
        if (!primaryImageTag.isNullOrEmpty()) {
            builder?.appendQueryParameter("tag", primaryImageTag)
        }
        return builder?.build()?.toString() ?: ""
    }
}
